package com.ipartek.formacion.migracion.main;

import java.util.ArrayList;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import com.ipartek.formacion.migracion.beans.Persona;
import com.ipartek.formacion.migracion.ddbb.DAOFactory;
import com.ipartek.formacion.migracion.interfaces.InterfacePersonaDao;

public class Principal {

	// ATRIBUTOS DE CONEXION SQL
	private static DAOFactory myDAO = DAOFactory
			.getDAOFactory(DAOFactory.MYSQL);

	// DAO PERSONA SQL
	public static InterfacePersonaDao personaSqlDAO = myDAO
			.getInterfacePersona();

	// ATRIBUTOS DE CONEXION TXT
	private static DAOFactory txtDAO = DAOFactory
			.getDAOFactory(DAOFactory.TXTFILE);

	// DAO PERSONA TXT
	public static InterfacePersonaDao personaTxtDAO = txtDAO
			.getInterfacePersona();

	// Variable para guardar los logs de error
	private static final Logger log = Logger.getLogger(Principal.class);

	public static void main(String[] args) {

		System.out.println("INICIO");

		PropertyConfigurator.configure("config/log4j.properties");

		ArrayList<Persona> lista = new ArrayList<Persona>();

		lista = personaTxtDAO.getPersonas();

		personaSqlDAO.conectar();
		for (Persona p : lista)
			personaSqlDAO.anadirPersona(p);

		personaSqlDAO.comitar();
		System.out.println("FIN");
	}

}
